-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract pattern metadata (title & description) #312
Extract pattern metadata (title & description) #312
Conversation
For this to be actually useful, Gutenberg should also actually translate the title. I don't see any |
Yeah, I need to follow-up with that as well :) |
I've prepared the Gutenberg PR that uses this data at WordPress/gutenberg#40047 but I'm having some trouble to get the translated strings. |
/patterns
Pending some tests this looks good to go! 👍 |
Tests would need to wait until tomorrow morning :) |
@swissspidy pushed the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Just one nit
Co-authored-by: Pascal Birchler <[email protected]>
$options = [ | ||
// Extract 'Title' and 'Description' headers from pattern files. | ||
'wpExtractPatterns' => isset( $this->main_file_data['Theme Name'] ), | ||
'include' => array_merge( $this->include, array( 'patterns' ) ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swissspidy Do you know why this hardcodes patterns
here? Since these are PHP files they should be included by default. Now you explicitly have to exclude the patterns
when you for example are using --include=wp-admin/*
. to only include wp-admin strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose the idea was to make this more efficient and only scan these files when needed.
But you're right that this is already covered by the call above. I'll create a PHP to combine these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… command. Ensures that strings from Twenty Twenty-Two are not included in POT files for wp-admin. See wp-cli/i18n-command#312 (review). git-svn-id: https://meta.svn.wordpress.org/sites/trunk@11809 74240141-8908-4e6f-9713-ba540dce6ec7
…irmly by ignoring the `wp-content` directory entirely for these admin contexts. It appears that the command does not fully respect the `exclude` parameter if it believes there are strings that should be included. By excluding a higher-level directory, it never see's the potential included `patterns` folder. Ensures that strings from Twenty Twenty-Two are not included in POT files for wp-admin. Previously: [11809]. See wp-cli/i18n-command#312 (review) git-svn-id: https://meta.svn.wordpress.org/sites/trunk@11810 74240141-8908-4e6f-9713-ba540dce6ec7
In WordPress/gutenberg#36751 Gutenberg added the ability to automatically register patterns that live in the
/patterns
directory. These patterns provide metadata via headers in the PHP file as in:From the existing metadata, we need the
Title
to be translatable. This PR adds support for looking up those patterns and extracting the Title string into the pot file.How to test
foo-theme
directory at the top-level, which contains the following files:style.css
with at least these contents:patterns/my-pattern.php
with at least these contents:foo-theme/foo-theme.pot
file has been generated and that contains the pattern title and the theme name. You should get something along these lines: